package safari.model.faq;

import java.sql.SQLException;

import safari.model.common.ListVO;
import safari.model.common.PagingBean;

public class FAQServiceImpl implements FAQService {
	private FAQDao fao;
	public FAQServiceImpl(FAQDao fao) {
		super();
		this.fao = fao;
	}
	/**
	 * 글을 등록한다. 조회수는 증가하지 않는다.
	 */
	@Override
	public void writeBoard(FAQBoardVO fvo) throws SQLException {
		fao.insertBoard(fvo);
	}
	/**
	 * 글번호를 인자값으로 해서 등록했던 글을 삭제한다.
	 */
	@Override
	public void deleteBoard(int no) throws SQLException {
		fao.deleteBoard(no);
	}
	/**
	 * 글을 수정한다. 
	 */
	@Override
	public void updateBoard(FAQBoardVO fvo) throws SQLException {
		fao.updateBoard(fvo);
	}
	/**
	 * 글의 상세보기를 담당
	 */
	@Override
	public FAQBoardVO getBoardByNo(int no) throws SQLException {
		return fao.selectBoardByNo(no);
		
	}
	/**
	 * 모든 글 목록을 조회
	 */
	@Override
	public ListVO getAllBoard() throws SQLException {
		int totalContents = fao.getTotalContents();
		PagingBean pb = new PagingBean(totalContents);
		ListVO lvo = new ListVO(fao.selectAllBoard(), pb);
		return lvo; 
	}
/*
	@Override
	public ListVO findBoardByTitle(String title) throws SQLException {
		int totalContents = fao.getTotalContentsByTitle(title);
		PagingBean pb = new PagingBean(totalContents);
		ListVO lvo = new ListVO(fao.selectBoardByTitle(title), pb);
		return lvo;
	}

	@Override
	public ListVO findBoardByContent(String content) throws SQLException {
		int totalContents = fao.getTotalContentsByContent(content);
		PagingBean pb = new PagingBean(totalContents);
		ListVO lvo = new ListVO(fao.selectBoardByContent(content), pb);
		return lvo;
	}

	@Override
	public ListVO findBoardByTitleOrContent(String keyword) throws SQLException {
		int totalContents = fao.getTotalContentsByTitleOrContent(keyword);
		PagingBean pb = new PagingBean(totalContents);
		ListVO lvo = new ListVO(fao.selectBoardByTitleOrContent(keyword), pb);
		return lvo;
	}*/
	//카테고리로 게시글 찾는 메서드
	@Override
	public ListVO findBoardByCategory(String category) throws SQLException {
		int totalContents = fao.getTotalContentsByCategory(category);
		PagingBean pb = new PagingBean(totalContents);
		ListVO lvo = new ListVO(fao.selectBoardByCategory(category), pb);
		return lvo;
	}
	//미구현
	@Override
	public ListVO findBoardByTitle(String title) throws SQLException {
		
		return null;
	}
	//미구현
	@Override
	public ListVO findBoardByContent(String content) throws SQLException {
		
		return null;
	}
	//미구현
	@Override
	public ListVO findBoardByTitleOrContent(String keyword) throws SQLException {
		
		return null;
	}
	
}
